package com.yyf.springboot2.controller;

import com.alibaba.fastjson.JSONObject;
import com.yyf.springboot2.common.ResultBean;
import com.yyf.springboot2.entity.TGoodscategory;
import com.yyf.springboot2.service.TGoodscategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yyf
 * @since 2019-05-29
 */
@Controller
@RequestMapping("/tGoodscategory")
public class TGoodscategoryController {

    @Resource
    private TGoodscategoryService tGoodscategoryService;

    @GetMapping("/all")
    @ResponseBody
    public ResultBean allCategory(){
        Map<String,Object> map = new HashMap <>();
        List<TGoodscategory> all =  tGoodscategoryService.list();
        map.put("categories",all);
        JSONObject jsons = new JSONObject(map);
        System.out.println("/all");
        return ResultBean.build(200,"",jsons);
    }



}
